// written by Ray Zeller and Alex Keybl

#include "Filter.h"
//#include "XMLPARSER.h"

#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <sstream>
	
	
Filter::Filter(vector<Event*> testEvents) {
	myEvents=testEvents;	
}

vector<Event*> Filter::filterDescriptions(string desc) {
	vector<Event*> filteredEvents;
	for(unsigned int i = 0; i<myEvents.size(); i++)
		if(myEvents[i]->getDescription()==desc)
			filteredEvents.push_back(myEvents[i]);
	return filteredEvents;
}

vector<Event*> Filter::filterDates(int date) {
	vector<Event*> filteredEvents;
	for(unsigned int i = 0; i<myEvents.size(); i++)
		if(date==myEvents[i]->getDay())
			filteredEvents.push_back(myEvents[i]);
	return filteredEvents;
}

vector<Event*> Filter::filterTimes(int start) {
	vector<Event*> filteredEvents;
	for(unsigned int i = 0; i<myEvents.size(); i++) {
		//cout<<"("<<myEvents[i].getStart()<<", "<<myEvents[i].getEnd()<<") - (" << start << ", " << start+1<<")"<<endl;
		if(myEvents[i]->getStart()==start)
			filteredEvents.push_back(myEvents[i]);
	}
	return filteredEvents;
}
